﻿using System;
using System.Web;
using System.Web.Configuration;

public partial class MasterPage : System.Web.UI.MasterPage
{
    protected void Page_Init(object sender, EventArgs e)
    {
        if (Session[AppConfig.SESSION_USER_ISLOGIN] != null && Session[AppConfig.SESSION_USER_ISLOGIN].ToString() == "1")
        {

        }
        else
        {
            Response.Redirect("/login.aspx?return=" + HttpUtility.UrlEncode(Request.Url.AbsoluteUri));
        }
    }

    protected void Page_Load(object sender, EventArgs e)
    {
        lblSYSName.Text = WebConfigurationManager.AppSettings["SYSName"].ToString();
        lblSYSNameEn.Text = WebConfigurationManager.AppSettings["SYSNameEn"].ToString();
        lblCopyright.Text = WebConfigurationManager.AppSettings["Copyright"].ToString();

        lblUserAccount1.Text = Session[AppConfig.SESSION_USER_ACCOUNT].ToString();
        //lblUserAccount2.Text = Session[AppConfig.SESSION_USER_ACCOUNT].ToString();
        lblUserName1.Text = Session[AppConfig.SESSION_USER_NAME].ToString();
        //lblUserName2.Text = Session[AppConfig.SESSION_USER_NAME].ToString();
        //lblUserName3.Text = Session[AppConfig.SESSION_USER_NAME].ToString();

        lblNavigation.Text = RolePermissionsHelper.createNavigationHtml(Session[AppConfig.SESSION_USER_ROLE_ID].ToString());
    }

    protected void btnLogout_Click(object sender, EventArgs e)
    {
        Session[AppConfig.SESSION_USER_ISLOGIN] = null;
        Response.Redirect("/login.aspx?return=" + HttpUtility.UrlEncode(Request.Url.AbsoluteUri));
    }
}
